
#include "UmlExt.h"
#include "GOAL.h"
#include "CastMap.h"

// this is meant to be VERY temporary. I need to get this interpreter
// working, and I'm taking some shortcuts. However, this should be AT
// LEAST encapsulated in a singleton, with setupCastMap as a singleton
// function

// static map of Uml::Class to UDM casting function
static std::map <Uml::Class, Udm::ObjectImpl * (*)(const Udm::Object &)> casts_;
static bool initialized_ = false;

// setup the map
void GOAL::setupCastMap(void)
{
/*  casts_[GOAL::ClassAdapter::meta] = reinterpret_cast
    <GOAL::MgaObject (*)(const Udm::Object &)> (&GOAL::ClassAdapter::Cast);
  casts_[GOAL::ModuleAdapter::meta] = reinterpret_cast
    <GOAL::MgaObject (*)(const Udm::Object &)> (&GOAL::ModuleAdapter::Cast);
  casts_[GOAL::Class::meta] = reinterpret_cast
    <GOAL::MgaObject (*)(const Udm::Object &)> (&GOAL::Class::Cast);
  casts_[GOAL::Module::meta] = reinterpret_cast
    <GOAL::MgaObject (*)(const Udm::Object &)> (&GOAL::Module::Cast);

  initialized_ = true; */
}

// cast the object to its true derived type. Why this isn't a part
// of the UDM generated code, I'll never know
Udm::ObjectImpl *
GOAL::castByMeta (const GOAL::MgaObject& source)
{
//  if (!initialized_) 
//    GOAL::setupCastMap ();


//  return Udm::Object::__Cast (source,source.meta);
  return NULL;
}
